<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;



class CreatePointTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('el_point', function (Blueprint $table) {
            $table->increments('id');

            $table->integer('user_id')->unsigned();

            //type:存在多种积分时用于分类
            $table->string('type')->default('default');

            //action:产生积分变化的动作，用于查询
            //  order_item:     订单商品获得积分
            //  order_discount: 订单折扣使用积分
            //  order_canceled: 取消订单返还积分
            //  goods:          线下购物获得积分(TNF导入数据)
            $table->string('action');

            //note:积分变化的提示信息，用于前台显示
            $table->string('note');

            //value:积分变化数值，可为负数
            $table->decimal('value',10,2)->nullable()->default(0);

            //valid_time:有效期(天)，0为永久有效
            $table->integer('valid_time')->nullable()->default(0);

            //item_id:积分变化动作对应表的id
            $table->integer('item_id');

            $table->string('item_type');

            $table->integer('status')->nullable()->default(1);

            $table->timestamps();
            $table->softDeletes();
            $table->engine = 'InnoDB';

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('el_point');
    }
}
